home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / gnu / fpu881 / src6.zoo / ctanh.c < prev    next >
C/C++ Source or Header  |  1991-09-24  |  2KB  |  81 lines

  1. /************************************************************************
  2.  *                                    *
  3.  *                N O T I C E                *
  4.  *                                    *
  5.  *            Copyright Abandoned, 1987, Fred Fish        *
  6.  *                                    *
  7.  *    This previously copyrighted work has been placed into the    *
  8.  *    public domain by the author (Fred Fish) and may be freely used    *
  9.  *    for any purpose, private or commercial.  I would appreciate    *
  10.  *    it, as a courtesy, if this notice is left in all copies and    *
  11.  *    derivative works.  Thank you, and enjoy...            *
  12.  *                                    *
  13.  *    The author makes no warranty of any kind with respect to this    *
  14.  *    product and explicitly disclaims any implied warranties of    *
  15.  *    merchantability or fitness for any particular purpose.        *
  16.  *                                    *
  17.  ************************************************************************
  18.  */
  19.  
  20.  
  21. /*
  22.  *  FUNCTION
  23.  *
  24.  *    ctanh   complex double precision hyperbolic tangent
  25.  *
  26.  *  KEY WORDS
  27.  *
  28.  *    ctanh
  29.  *    complex functions
  30.  *    machine independent routines
  31.  *    math libraries
  32.  *
  33.  *  DESCRIPTION
  34.  *
  35.  *    Computes double precision complex hyperbolic tangent of
  36.  *    a double precision complex argument.
  37.  *
  38.  *  USAGE
  39.  *
  40.  *    COMPLEX ctanh (z)
  41.  *    COMPLEX z;
  42.  *
  43.  *  PROGRAMMER
  44.  *
  45.  *    Fred Fish
  46.  *    Tempe, Az 85281
  47.  *    (602) 966-8871
  48.  *
  49.  *  INTERNALS
  50.  *
  51.  *    Computes complex hyperbolic tangent of Z = x + j y from:
  52.  *
  53.  *        ctanh(z) = (1 - cexp(-2z)) / (1 + cexp(-2z))
  54.  *
  55.  */
  56.  
  57. #include <stdio.h>
  58. #include <pmluser.h>
  59. #include "pml.h"
  60.  
  61.  
  62. COMPLEX ctanh (z)
  63. COMPLEX z;
  64. {
  65.     COMPLEX result;
  66.     extern COMPLEX cexp (), cdiv ();
  67.     
  68.     ENTER ("ctanh");
  69.     DEBUG4 ("ctanhin", "arg %le %le", z.real, z.imag);
  70.     result.real = -2.0 * z.real;
  71.     result.imag = -2.0 * z.imag;
  72.     result = cexp (result);
  73.     z.real = 1.0 - result.real;
  74.     z.imag = -result.imag;
  75.     result.real += 1.0;
  76.     result = cdiv (z, result);    
  77.     DEBUG4 ("ctanhout", "result %le %le", result.real, result.imag);
  78.     LEAVE ();
  79.     return (result);
  80. }
  81.